package xuhaijia.lanou3g.autohome.find;
//                .-~~~~~~~~~-._       _.-~~~~~~~~~-.
//            __.'              ~.   .~              `.__
//          .'//                  \./                   \\`.
//        .'//            为什么坚持  想一想当初             \\`.
//      .'// .-~"""""""~~~~-._     |     _,-~~~~"""""""~-.  \\`.
//    .'//.-"                 `-.  |  .-'                 "-. \\`.
//  .'//______.============-..   \ | /   ..-============._______\\`.
//.'//____________________________\|/_____________________________\\`.
// 
//                             

import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import java.text.ParseException;
import java.text.SimpleDateFormat;

import xuhaijia.lanou3g.autohome.R;
import xuhaijia.lanou3g.autohome.activity.RadioActivity;
import xuhaijia.lanou3g.autohome.base.NetTool;

/**
 * Created by 7 on 16/8/27.
 */
public class RadioAdapter extends BaseAdapter {
    Context context;
    RadioBean radioBean;
    NetTool mNetTool = new NetTool();



    public RadioAdapter(Context context) {
        this.context = context;
    }


    public void setRadioBean(RadioBean radioBean) {
        this.radioBean = radioBean;
        notifyDataSetChanged();
    }

    @Override
    public int getCount() {
        if (radioBean.getResult().getList() == null) {
            return 0;
        }
        return radioBean.getResult().getList().size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder = null;
        if (convertView == null) {
            convertView = LayoutInflater.from(context).inflate(R.layout.item_radio, null);
            viewHolder = new ViewHolder(convertView);
            convertView.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }
        mNetTool.getImage(radioBean.getResult().getList().get(position).getRadiopicurl(), viewHolder.iv);
        viewHolder.contentTv.setText(radioBean.getResult().getList().get(position).getContent());
        viewHolder.nameTv.setText(radioBean.getResult().getList().get(position).getAlbum());
        viewHolder.timeTv.setText(radioBean.getResult().getList().get(position).getProgramtime());
        return convertView;
    }

    private class ViewHolder {
        ImageView iv;
        TextView nameTv;
        TextView contentTv;
        TextView timeTv;

        public ViewHolder(View view) {
            iv = (ImageView) view.findViewById(R.id.item_radio_iv);
            nameTv = (TextView) view.findViewById(R.id.item_radio_name);
            contentTv = (TextView) view.findViewById(R.id.item_radio_content);
            timeTv = (TextView) view.findViewById(R.id.item_radio_time);
        }
    }


}
